package com.siren.tank.cor;

import com.siren.tank.GameObject;
import com.siren.tank.group.BaseTank;

/**
 * @author : wangjichao
 * @description:
 * @date : 2020/8/8 10:02
 */
public class TankTankCollider implements Collider {
    @Override
    public boolean collide(GameObject o1, GameObject o2) {
        if (o1 instanceof BaseTank && o2 instanceof BaseTank) {
            BaseTank b1 = (BaseTank) o1;
            BaseTank b2 = (BaseTank) o2;
            if (isIntersection(b1.getX(), b1.getY(), BaseTank.WIDTH, BaseTank.HEIGHT,
                    b2.getX(), b2.getY(), BaseTank.WIDTH, BaseTank.HEIGHT)) {
                b1.back();
                b2.back();
                return false;
            }
        }
        return true;
    }
}
